<template>
  <div class="not-found-container">
    <div class="not-found-content">
      <div class="error-code">404</div>
      <div class="error-icon">
        <el-icon class="icon"><WarningFilled /></el-icon>
      </div>
      <h1 class="error-title">页面不存在</h1>
      <p class="error-subtitle">抱歉，您访问的页面已被移动或不存在</p>
      <div class="actions">
        <el-button type="primary" size="large" @click="goToHome" class="home-button">
          <el-icon><HomeFilled /></el-icon>
          返回首页
        </el-button>
        <el-button type="info" size="large" @click="goBack" class="back-button">
          <el-icon><Back /></el-icon>
          返回上一页
        </el-button>
      </div>
    </div>
  </div>
</template>

<script setup>
import {useRouter} from 'vue-router';
import {WarningFilled, HomeFilled, Back} from '@element-plus/icons-vue';

const router = useRouter();

const goToHome = () => {
  const userType = localStorage.getItem('userType');
  if (!userType) {
    router.push('/login');
    return;
  }

  const homePath = userType === 'student' ? '/student/dashboard' : '/researcher/dashboard';
  router.push(homePath);
};

const goBack = () => {
  router.go(-1);
};
</script>

<style scoped>
.not-found-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

.not-found-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 500px;
  padding: 3rem;
  border-radius: 12px;
  background-color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.error-code {
  font-size: 8rem;
  font-weight: 700;
  color: #409EFF;
  line-height: 1;
  margin-bottom: 1rem;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.error-icon {
  margin: 1rem 0;
}

.icon {
  font-size: 3rem;
  color: #E6A23C;
}

.error-title {
  font-size: 2rem;
  font-weight: 600;
  color: #303133;
  margin: 0.5rem 0;
}

.error-subtitle {
  font-size: 1.2rem;
  color: #606266;
  margin: 1rem 0 2rem;
}

.actions {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

.home-button, .back-button {
  transition: transform 0.2s;
}

.home-button:hover, .back-button:hover {
  transform: translateY(-3px);
}

@media (max-width: 768px) {
  .not-found-content {
    padding: 2rem;
    margin: 0 1rem;
  }

  .error-code {
    font-size: 6rem;
  }

  .actions {
    flex-direction: column;
  }
}
</style>